var webID = "";//网站ID
var webColor = "";//导航颜色
var webAbstract = "";//公司简介
var webLinkman = "";//联系人
var webPhone = "";//联系电话
var webAddress = "";//联系地址
var siteID = "";//域名siteID
$(function () {
    var pTitle = "";//项目标题对象
    var pSubTitle = "";//项目小标题对象
    var titleHide = "";//隐藏标题栏对象
    var imgHide = "";//文章图片是否隐藏
    var aObj = null;
    var inputObj = null;
    var page = 1;//当前页数
    var pageNum = 5;//每页展示多少条数据
    var addOrEdit = 0;//(0 add 1 edit)
    var articleID = "";
    var articleList = null;//文章列表对象
    var articleEditor = new Simditor({
        textarea:$('#articleEditor'),
        toolbar:['title','bold','italic','underline','strikethrough','color','ol','ul','blockquote','code','link','alignment']
    });
    /*
    * 初始化数据（页面panelist，文章articletypelist，相册phototypelist）
    * */
    //获取域名的siteID
    siteID = getQueryString("siteid");
    //清除所有缓存
    localStorage.clear();
    $.ajax({
        url:"/action/web_cmd.asp?act=all_list&siteid="+siteID,
        type:"get",
        dataType:"json",
        success:function (data) {
            if(data.status == 0){//成功
                //网站模板
                var templetStr = "";
                $.each(data.moban.mblist,function(index,value){
                    templetStr += "<div class='templetItem'>" +
                                    "<div class='templetImg' data-id='"+value.siteid+"'>" +
                                        "<img src='"+value.moban_pic+"' width='100%' height='100%'>" +
                                        "<div class='templetIntro'>精品搬家服务模板</div>" +
                                    "</div>" +
                                    "<div class='templetAction'>" +
                                        "<button style='background: "+value.fengge+";' class='btn btn-xs'>&ensp;&ensp;&ensp;</button>" +
                                        "<button class='btn btn-xs btn-success pull-right templetUsed' data-id='"+value.siteid+"'>选择该模板</button>" +
                                    "</div>" +
                                "</div>";
                });
                $(".templetList").html(templetStr);
                //网站页面
                var pageList = data.page.pagelist;
                var html = "";
                var radioHtml = "";
                var navStr = "";
                pageIDsArr = [];
                $.each(pageList,function (index,value) {
                    //获取页面html
                    getPageHtml(siteID,value.pageid);
                    if(value.pageid != 1){
                        html += "<div class='leftMainItem' data-id='"+value.pageid+"'>" +
                            "<i class='fa fa-bars icox' data-sort='"+value.paixu+"'></i>"+
                            "<a href='javascript:;' class='leftMainItemName'>"+value.pagename+"</a>"+
                            "<input type='text' style='display: none;' class='inputLeftMainItemName inputPageName' data-id='"+value.pageid+"'>"+
                            "<span class='edit'>"+
                            "<a class='leftMainItemNameEdit pageCarousel' data-toggle='modal' data-target='#fullCarouse' data-id='"+value.pageid+"'><i class='fa fa-picture-o'></i></a>"+
                            "<a href='javascript:;' class='leftMainItemNameEdit pageNameEdit'><i class='fa fa-pencil'></i></a>"+
                            "<a href='javascript:;' class='pageDel' data-id='"+value.pageid+"'><i class='fa fa-remove'></i></a>"+
                            "</span>"+
                            "</div>";
                        navStr += "<li><a href='#' data-id='"+value.pageid+"'>"+value.pagename+"</a></li>";
                    }else{
                        navStr = "<li class='active'><a href='#' data-id='"+value.pageid+"'>"+value.pagename+"</a></li>";

                    }
                    pageIDsArr.push(value.pageid);
                });
                $("#pageList").html(html);
                $("#nav").html(navStr);
                $(".myNav").html(navStr);
                //文章文件夹列表
                html = "";
                var articleTypeList = data.articletype.typelist;
                $.each(articleTypeList,function(index,value){
                    html += "<div class='leftMainItem' data-id='"+value.typeid+"'>"+
                        "<i class='fa fa-bars icox'></i>"+
                        "<a class='leftMainItemName articleFolderName' data-toggle='modal' data-target='#editArticle'>"+value.typename+"</a>"+
                        "<input type='text' style='display: none;' class='inputLeftMainItemName inputArticleFolderName' data-id='"+value.typeid+"'>"+
                        "<span class='edit'>"+
                        "<a href='javascript:;' class='leftMainItemNameEdit articleFolderNameEdit'><i class='fa fa-pencil'></i></a>"+
                        "<a href='javascript:;' class='articleFolderDel' data-id='"+value.typeid+"'><i class='fa fa-remove'></i></a>"+
                        "</span>"+
                        "</div>";
                    radioHtml += "<label class='radio-inline'>"+
                                    "<input type='radio' name='inlineRadioOptions' value='"+value.typeid+"'> "+value.typename+
                                "</label>"
                });
                $("#articleList").html(html);
                $("#articleFolderList").html(radioHtml);
                //相册文件夹列表
                html = "";
                var photoTypeList = data.phototype.typelist;
                $.each(photoTypeList,function(index,value){
                    html += "<div class='leftMainItem' data-id='"+value.typeid+"'>"+
                        "<i class='fa fa-bars icox'></i>"+
                        "<a class='leftMainItemName albumFolderName' data-toggle='modal' data-target='#editAlbumContent'>"+value.typename+"</a>"+
                        "<input type='text' style='display: none;' class='inputLeftMainItemName inputAlbumFolderName' data-id='"+value.typeid+"'>"+
                        "<span class='edit'>"+
                        "<a href='javascript:;' class='leftMainItemNameEdit albumFolderNameEdit'><i class='fa fa-pencil'></i></a>"+
                        "<a href='javascript:;' class='albumFolderDel' data-id='"+value.typeid+"'><i class='fa fa-remove'></i></a>"+
                        "</span>"+
                        "</div>";
                });
                $("#albumList").html(html);

                webID = data.webset.wid;
                webColor = data.webset.webcolor;
                webAbstract = data.webset.qyjj;
                webLinkman = data.webset.lxr;
                webPhone = data.webset.lxdh;
                webAddress = data.webset.gsdz;
                $("#elmBase").find(".box .view .contactCnt .company-desc .the-desc").html("<p>"+webAbstract+"</p>");
                $("#elmBase").find(".box .view .contactCnt .contact-type .the-linkman").html(webLinkman);
                $("#elmBase").find(".box .view .contactCnt .contact-type .the-phone").html(webPhone);
                $("#elmBase").find(".box .view .contactCnt .contact-address .the-address").html(webAddress);
                //---------------导航菜单样式----------------
                $(".navbar-default").find("a").hover(function () {
                    $(this).parent().css("background",webColor);
                }).mouseout(function () {
                    $(this).parent(":not('.active')").css("background","#000");
                });
                $(".navbar-default").find("a").focus(function () {
                    $(this).parent().css("background",webColor);
                }).blur(function(){
                    $(this).parent(":not('.active')").css("background","#000");
                });
                $(".navbar-default").find(".active").css("background",webColor);
                //头部样式
                $("#logo").attr("src",data.webset.weblogo);
                $(".headerContactIcon").css("color",webColor);
                $(".headerContactTitle").css("color",webColor);
                $(".headerContactTel").html(data.webset.lxdh);
                //底部样式
                $("footer").css("border-top","4px solid "+webColor);
                $(".webBottom").html(data.webset.webbot);
                //设置信息
                $("#webUrl").html(data.webset.weburl);
                $("#comName").html(data.webset.webname);
                $("#comPro").html(data.webset.qyjj);
                $("#comAddress").html(data.webset.gsdz);
                $("#comContact").html(data.webset.lxr);
                $("#comContactTel").html(data.webset.lxdh);
                $("#SEOTitleShow").html(data.webset.seotitle);
                $("#SEOKeyShow").html(data.webset.seokey);
                $("#SEODescShow").html(data.webset.seodes);
                $("#shareTitleShow").html(data.webset.share_title);
                $("#shareDescShow").html(data.webset.share_des);
                $("#shareImg").attr('src',data.webset.share_pic);
                //预览
                $("#sourcepreview").attr("href",data.webset.weburl);
                $("#sub-tel").html(data.webset.lxdh);
                //头部背景
                var headBg = data.webset.top_bg;
                var footBg = data.webset.bot_bg;
                if(headBg != ""){
                    var headBgArr = headBg.split("|");
                    $("#headBg").spectrum("set",headBgArr[0]);
                    $("#headBgImg").attr("src",headBgArr[1]);
                    $("#headBgRepeat").val(headBgArr[2]);
                    $("#headBgPosition").val(headBgArr[3]);
                    $("#header").css("background",headBgArr[0]+" url("+headBgArr[1]+") "+headBgArr[2]+" "+headBgArr[3]);
                }
                //底部背景
                if(footBg != ""){
                    var footBgArr = footBg.split("|");
                    $("#footBg").spectrum("set",footBgArr[0]);
                    $("#footBgImg").attr("src",footBgArr[1]);
                    $("#footBgRepeat").val(footBgArr[2]);
                    $("#footBgPosition").val(footBgArr);
                    $("#footer").css("background",footBgArr[0]+" url("+footBgArr[1]+") "+footBgArr[2]+" "+footBgArr[3]);
                }
            }else if(data.status == 120){
                window.location.href = "http://www.bjzwsl.com/login/";
            }
        }
    });
    //获取客服悬浮框
    $.ajax({
        url:"/action/web_cmd.asp?act=kefu_show",
        type:"get",
        success:function(data){
            var jsondata = $.parseJSON(data);
            $(".suspension .a").css("background-color",jsondata.bgcol);
            $("#sus-qq").html(jsondata.qq).parent("a").attr("href","http://wpa.qq.com/msgrd?v=3&uin="+jsondata.qq+"&site=qq&menu=yes");
            $("#qrcode-img").children("img").attr("src",jsondata.wxcode);
        }
    });

    //页面列表排序
    $("#pageList").sortable({
        stop: function( event, ui ) {
            var pageIDs = $("#pageList").sortable("toArray",{
                attribute:"data-id"
            }).join(",");
            $.ajax({
                url:"/action/web_cmd.asp?act=page_px",
                type:"post",
                dataType:"json",
                data:{
                    pageids:pageIDs
                },
                success:function (data) {
                    //console.log(data);
                    if(data.status == 0){
                        getPageInfo();
                    }
                }
            })
        }
    });
    //添加页面
    $("#pageAdd").click(function(){
        $(this).siblings("#inputPageAdd").show().focus();
    });
    //添加页面blur
    $("#inputPageAdd").blur(function () {
        var pageName = $(this).val();
        if(pageName.length == 0){
            $("#inputPageAdd").hide();
            return false;
        }else if(pageName.length > 10){
            alert("网站名称不能超过10个字符！");
            return false;
        }
        $.ajax({
            url:"action/web_cmd.asp?act=page_add",
            type:"post",
            dataType:"json",
            data:{
                pagename:pageName
            },
            async:false,
            success:function(data){
                if(data.status == 0){
                    var html = "<div class='leftMainItem' data-id='"+data.pageid+"'>" +
                        "<i class='fa fa-bars' data-sort='"+data.paixu+"'></i>"+
                        "<a href='"+data.pageurl+"' class='leftMainItemName'>"+data.pagename+"</a>"+
                        "<input type='text' style='display: none;' class='inputLeftMainItemName inputPageName' data-id='"+data.pageid+"'>"+
                        "<span class='edit'>"+
                        "<a class='leftMainItemNameEdit pageCarousel' data-toggle='modal' data-target='#fullCarouse' data-id='"+value.pageid+"'><i class='fa fa-picture-o'></i></a>"+
                        "<a href='javascript:;' class='leftMainItemNameEdit pageNameEdit'><i class='fa fa-pencil'></i></a>"+
                        "<a href='javascript:;' class='pageDel' data-id='"+data.pageid+"'><i class='fa fa-remove'></i></a>"+
                        "</span>"+
                        "</div>";
                    $("#pageList").append(html);
                    $("#inputPageAdd").hide();
                    getPageInfo();
                }else{
                    alert(data.message);
                }
            }
        })
    });
    //编辑页面名称
    $(document).on("click",".pageNameEdit",function(e){
        e.preventDefault();
        aObj = $(this).parents(".edit").siblings(".leftMainItemName");
        inputObj = $(this).parent(".edit").siblings(".inputLeftMainItemName");
        inputObj.val(aObj.html());
        aObj.hide();
        inputObj.show().focus();
    });
    //编辑页面失去焦点
    $(document).on("blur",".inputPageName",function () {
        var pageID = $(this).attr("data-id");
        var pageName = $(this).val();
        if(pageName.length > 10){
            alert("网站名称不能超过10个字符！");
            return false;
        }
        $.ajax({
            url:"/action/web_cmd.asp?act=page_edit",
            type:"post",
            dataType:"json",
            data:{
                pageid:pageID,
                pagename:pageName
            },
            success:function(data){
                if(data.status == 0){
                    inputObj.hide();
                    aObj.html(pageName);
                    aObj.show();
                    getPageInfo();
                }else{
                    alert(data.message);
                }
            }
        })

    });
    //删除页面
    $(document).on("click",".pageDel",function(){
        if(confirm("确定要删除该页面吗")){
            var pageID = $(this).attr("data-id");
            var thisObj = $(this);
            $.ajax({
                url:"/action/web_cmd.asp?act=page_del",
                type:"post",
                dataType:"json",
                data:{
                    pageid:pageID
                },
                success:function(data){
                    if(data.status == 0){
                        thisObj.parents(".leftMainItem").remove();
                        getPageInfo();
                    }else{
                        alert("页面删除失败");
                    }
                }
            })
        }
    });
    //获取全屏轮播数据
    $(document).on("click","[data-target=#fullCarouse]",function() {
        var pageid = $(this).attr("data-id");
        $.ajax({
            url:"/action/web_cmd.asp?act=qpt_show",
            type:"post",
            data:{
                pageid:pageid
            },
            success:function(data) {
                var jsondata = $.parseJSON(data);
                if(jsondata.status == 0){
                    for(var i = 0; i < jsondata.piclist.length; i++){
                        $("#fullImg"+(i+1)).attr("src",jsondata.piclist[i].tu);
                        $("#fullLink"+(i+1)).val(jsondata.piclist[i].link);
                    }
                }
            }
        })
    });

    //全屏轮播设置函数
    $("#saveFullImg").click(function(){
        $.ajax({
            url:"/action/web_cmd.asp?act=qpt_set",
            type:"post",
            data:{
                pageid:$(".pageAct").parent(".leftMainItem").attr("data-id"),
                qpstr:$("#fullImg1").attr("src")+","+$("#fullLink1").val()+"|"+$("#fullImg2").attr("src")+","+$("#fullLink2").val()+"|"+$("#fullImg3").attr("src")+","+$("#fullLink3").val()+"|"+
                    $("#fullImg4").attr("src")+","+$("#fullLink4").val()+"|"+$("#fullImg5").attr("src")+","+$("#fullLink5").val()
            },
            success:function(data) {
                var jsondata = $.parseJSON(data);
                if(jsondata.status == 0){
                    $('#fullCarouse').modal('hide');
                }else{
                    alert("设置失败！");
                }
            }
        })
    });

    //添加文件夹
    $("#articleFolderAdd").click(function () {
        $(this).siblings("#inputArticleFolderAdd").show().focus();
    });
    //添加文章失去焦点
    $("#inputArticleFolderAdd").blur(function () {
        var typeName = $(this).val();
        var thisObj = $(this);
        if(typeName.length == 0){
            thisObj.hide();
            return false;
        }else if(typeName.length > 10){
            alert("文件夹的名称不能超过10个");
            return false;
        }
        $.ajax({
            url:"/action/article.asp?act=addtype",
            type:"post",
            dataType:"json",
            data:{
                typenames:typeName
            },
            success:function(data){
                if(data.status == 0){
                    var html = "<div class='leftMainItem' data-id='"+data.typeid+"'>"+
                        "<i class='fa fa-bars icox'></i>"+
                        "<a class='leftMainItemName articleFolderName' data-toggle='modal' data-target='#editArticle'>"+data.typename+"</a>"+
                        "<input type='text' style='display: none;' class='inputLeftMainItemName inputArticleFolderName' data-id='"+data.typeid+"'>"+
                        "<span class='edit'>"+
                        "<a href='javascript:;' class='leftMainItemNameEdit articleFolderNameEdit'><i class='fa fa-pencil'></i></a>"+
                        "<a href='javascript:;' class='articleFolderDel' data-id='"+data.typeid+"'><i class='fa fa-remove'></i></a>"+
                        "</span>"+
                        "</div>";
                    $("#articleList").append(html);
                    thisObj.hide();
                }else{
                    alert(data.message);
                }

            }
        })
        //$(this).hide();
    });
    //文章夹名称编辑
    $(document).on("click",".articleFolderNameEdit",function () {
        aObj = $(this).parent().siblings(".articleFolderName");
        inputObj = $(this).parent().siblings(".inputArticleFolderName");
        var txt = aObj.html();
        aObj.hide();
        inputObj.val(txt);
        inputObj.show().focus();
    });
    //文件夹编辑失去焦点
    $(document).on("blur",".inputArticleFolderName",function(){
        var aticleTypeID = $(this).attr("data-id");
        var articleTypeName = $(this).val();
        if(articleTypeName.length > 10){
            alert("文件夹的名称不能超过10个字符");
            return false;
        }
        $.ajax({
            url:"/action/article.asp?act=editarttls",
            type:"post",
            dataType:"json",
            data:{
                typeid:aticleTypeID,
                typenames:articleTypeName
            },
            async:false,
            success:function(data){
                if(data.status == 0){
                    inputObj.hide();
                    aObj.html(articleTypeName);
                    aObj.show();
                }else{
                    alert(data.message);
                }
            }
        })
    })
    //文件夹删除
    $(document).on("click",".articleFolderDel",function(){
        if(confirm("确认要删除此文件夹吗，删除后该文件夹内容将会清空")){
            var articleTypeID = $(this).attr("data-id");
            var thisObj = $(this);
            $.ajax({
                url:"/action/article.asp?act=delarttls",
                type:"post",
                dataType:"json",
                data:{
                    typeid:articleTypeID
                },
                success:function(data){
                    if(data.status == 0){
                        thisObj.parents(".leftMainItem").remove();
                    }else{
                        alert("文件夹删除失败");
                    }
                }
            })
        }
    });
    //编辑文章返回
    $(".articleBack").click(function () {
        $(this).parents(".modal-content").hide().siblings(".modal-content").show();
    });
    //文章编辑
    $(".articleEdit").click(function () {
        $(this).parents(".modal-content").hide().siblings(".modal-content").show();
    });
    //文章文件夹列表编辑
    //编辑文章展示打开
    $('body').on("click","[data-target=#editArticle]",function(e) {
        e.preventDefault();
        var articleTypeName = $(this).html();
        var articleTypeID = $(this).parents(".leftMainItem").attr("data-id");
        $("#articleFolderName").html(articleTypeName);
        $("#articleFolderName").attr("data-id",articleTypeID);
        getArticleList(articleTypeID,page,pageNum)
    });
    //(文章列表)添加文章页面打开
    $("#articleAdd").click(function () {
        addOrEdit = 0;
        articleID = "";
        $(this).parents(".modal-content").hide().siblings(".modal-content").show();

    });
    //(文章列表)编辑文章页面打开
    $(document).on("click",".articleEdit",function () {
        addOrEdit = 1;
        articleID = $(this).attr("data-id");
        $(this).parents(".modal-content").hide().siblings(".modal-content").show();
        $.ajax({
            url:"/action/article.asp?act=show_art&articleid="+articleID,
            type:"get",
            dataType:"json",
            success:function(data){
                if(data.status == 0){
                    $("#articleTitle").val(data.title);
                    articleEditor.setValue(data.content);
                    $("#postPic").attr("src",data.picstr);
                }
            }
        })
    })
    //添加文章(编辑文章)
    $("#addArticle").click(function () {
        var typeID = $(this).parents("#editArticle").find("#articleFolderName").attr("data-id");
        var cont = articleEditor.getValue();
        var title = $("#articleTitle").val();
        var postUrl = $("#postPic").attr("src");
        var url = "";
        var data = {};
        if(addOrEdit == 0){//添加文章
            url = "/action/article.asp?act=add_art";
            data = {
                title:title,
                content:cont,
                picstr:postUrl,
                typeid:typeID
            }
        }else{//编辑文章
            url = "/action/article.asp?act=edit_art";
            data = {
                articleid:articleID,
                title:title,
                content:cont,
                picstr:postUrl,

            }
        }
        $.ajax({
            url:url,
            type:"post",
            dataType:"json",
            data:data,
            success:function(data){
                if(data.status == 0){
                    getArticleList(typeID,page,pageNum);
                    $("#addArticle").parents(".modal-content").hide().siblings(".modal-content").show();
                    updateArticleShow(typeID);
                }
            }
        })
    });
    //删除文章
    $("#delArticle").click(function () {
        if(articleID != ""){
            $.ajax({
                url:"/action/article.asp?act=del_art",
                type:"post",
                dataType:"json",
                data:{
                    articleid:articleID
                },
                success:function (data) {
                    if(data.status == 0){
                        var typeID = $("#delArticle").parents("#editArticle").find("#articleFolderName").attr("data-id");
                        getArticleList(typeID,page,pageNum);
                        $("#addArticle").parents(".modal-content").hide().siblings(".modal-content").show();
                        updateArticleShow($("#delArticle").parents("#editArticle").find("#articleFolderName").attr("data-id"));
                    }
                }
            })
        }
    })
    //上传封面
    $('#postUploader').fileupload({
        url: '/action/upload/',
        dataType: 'json',
        add: function (e, data) {
            var filename = data.files[0].name;
            var namerex = /^(.+[.])(jpg|png|gif|bmp)$/i;
            if(namerex.test(filename)) {
                data.formData = { fileinpname: 'pic', time: Date() }
                data.submit();
            }else {
                alert('只能上传jpg、png、gif、bmp格式的图片文件');
            }
        },
        done: function (e, data) {
            if(data.result && data.result.status=='0') {
                var filename = data.files[0].name;
                filename = filename.substring(0,filename.length-4);
                $("#postPic").attr("src",data.result.relatPath);
            }
        }
    });
    //上传文章插图
    $('#picUploader').fileupload({
        url: '/action/upload/',
        dataType: 'json',
        add: function (e, data) {
            var filename = data.files[0].name;
            var namerex = /^(.+[.])(jpg|png|gif|bmp)$/i;
            if(namerex.test(filename)) {
                data.formData = { fileinpname: 'pic', time: Date() }
                data.submit();
            }else {
                alert('只能上传jpg、png、gif、bmp格式的图片文件');
            }
        },
        done: function (e, data) {
            if(data.result && data.result.status=='0') {
                var filename = data.files[0].name;
                filename = filename.substring(0,filename.length-4);
                console.log(data.result.relatPath);
                var articleCont  =articleEditor.getValue() + "<img width='100%' src='"+data.result.relatPath+"' />";
                articleEditor.setValue(articleCont);
                //$("#postPic").attr("src",data.result.relatPath);
            }
        }
    });
    //编辑文章展示打开
    $(document).on("click","[data-target=#editDisplayArticle]",function(e) {
        e.preventDefault();
        pTitle = $(this).parent().parent().find('.view').find('.pTitle');
        pSubTitle = $(this).parent().parent().find(".view").find('.pSubTitle');
        titleHide = $(this).parent().parent().find(".view").find('.pTitleBox');
        imgHide = $(this).parent().parent().find(".view").find(".articleImg");
        articleList = $(this).parent().parent().find(".view").find(".articleList");
        $("#AProjectTitle").val(pTitle.html());
        $("#AProjectSubTitle").val(pSubTitle.html());
        //是否现实项目标题
        if(titleHide.hasClass('hidden')){
            $("#ATitleHide").attr("checked",true);
        }else{
            $("#ATitleHide").attr("checked",false);
        }
        //手机是否显示标题
        if(titleHide.hasClass('hidden-xs')){
            $("#AMobileHide").attr("checked",true);
        }else{
            $("#AMobileHide").attr("checked",false);
        }
        if(imgHide.hasClass("hidden")){
            $("#imgHide").attr("checked",true);
        }else{
            $("#imgShow").attr("checked",true);
        }
        if(articleList.attr("data-id") != undefined){
            $("input[name='inlineRadioOptions'][value='"+articleList.attr("data-id")+"']").attr("checked",true);
            $("#articleDisplayCount").val(articleList.attr("data-count"));
            $("input[name='imgShowOrHide'][value='"+articleList.attr("data-pic")+"']").attr("checked",true);
        }
    })
    //编辑文章展示保存
    $("#saveDisplayArticle").click(function(e){
        e.preventDefault();
        pTitle.html($("#AProjectTitle").val());
        pSubTitle.html($("#AProjectSubTitle").val());
        var folderID = $("input[name='inlineRadioOptions']:checked").val();
        var articleCount = $("#articleDisplayCount").val();
        var postPic = $("input[name='imgShowOrHide']:checked").val();
        if($("#ATitleHide").is(":checked")){
            titleHide.addClass("hidden");
        }else{
            titleHide.removeClass("hidden");
        }
        if($("#AMobileHide").is(":checked")){
            titleHide.addClass("hidden-xs");
        }else{
            titleHide.removeClass(("hidden-xs"));
        }
        if($("input[name='imgShowOrHide']:checked").val() == 1){
            imgHide.removeClass("hidden");
        }else{
            imgHide.addClass("hidden");
        }
        articleList.parent(".view").find("script").remove();
        articleList.attr({
            "data-id":folderID,
            "data-count":articleCount,
            "data-pic":postPic
        });
        var curID = articleList.attr("id");
        $("#script-"+curID).remove();
        var scriptStr = '<script id="script-'+curID+'" src="/action/articleshow.asp?aid='+curID+'&wid='+webID+'&typeid='+folderID+'&topnum='+articleCount+'&peitu='+postPic+'"></script>';
        articleList.parent(".view").append(scriptStr);
    });
    //获取页面信息列表
    function getPageInfo(){
        var navStr = "<li class='active'><a href='#' data-id='1'>网站首页</a></li>";
       $("#pageList").find(".leftMainItem").each(function () {
           navStr += "<li><a href='#' data-id='"+$(this).attr("data-id")+"'>"+$(this).children("a").html()+"</a></li>";
       });
        $("#nav").html(navStr);
        $(".myNav").html(navStr);
    }
    //获取对应文件夹列表
    function getArticleList(typeID,page,pageNum){
        $.ajax({
            url:"/action/article.asp?act=read_art_list&typeid="+typeID+"&page="+page+"&pagenum="+pageNum,
            type:"get",
            dataType:"json",
            success:function (data) {
                if(data.status == 0){
                    var str = "";
                    if(data.count > 0){
                        $.each(data.item,function (index,value) {
                            str += "<tr><td>"+(index+1)+"</td>"+
                                "<td><a href='javascript:;' class='articleEdit' data-id='"+value.articleid+"'>"+value.title+"</a></td>"+
                                "<td>"+value.addtime+"</td></tr>";
                        });
                        $('#pagination').jqPaginator({
                            totalPages: Math.ceil(data.count / 5),
                            visiblePages: 5,
                            currentPage: 1,
                            first: '<li class="first"><a href="javascript:void(0);">首页</a></li>',
                            prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
                            next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
                            last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
                            page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
                            onPageChange: function (num, type) {
                                if(type != "init"){
                                    analayArticleList(typeID,num,pageNum);
                                }
                            }
                        });
                    }else{
                        $("#pagination").empty();
                    }
                    $("#tbodyArticleList").html(str);
                }
            }
        })
    }
    function analayArticleList(typeID,page,pageNum){
        $.ajax({
            url:"/action/article.asp?act=read_art_list&typeid="+typeID+"&page="+page+"&pagenum="+pageNum,
            type:"get",
            dataType:"json",
            success:function (data) {
                if(data.status == 0){
                    var str = "";
                    $.each(data.item,function (index,value) {
                        str += "<tr><td>"+(index+1)+"</td>"+
                            "<td><a href='javascript:;' class='articleEdit' data-id='"+value.articleid+"'>"+value.title+"</a></td>"+
                            "<td>"+value.addtime+"</td></tr>";
                    })
                    $("#tbodyArticleList").html(str);
                }
            }
        })
    }
    //html页面更新文章展示列表
    function updateArticleShow(folderID){
        $("script[id*='script-article']").each(function(){
            var src = $(this).attr("src");
            var articleID = getParam(src,"aid");
            if(folderID == getParam(src,"typeid")){
                $("#script-" + articleID).remove();
                $(".demo").append("<script id='script-"+articleID+"' src='"+src+"'></script>");

            }
        })
    }
    //获取文章文件夹列表
    function getArticleFolderList(){
        $.ajax({
            url:"/action/article.asp?act=read_arttype_list",
            type:"get",
            dataType:"json",
            success:function(data){
                if(data.status == 0){

                }
            }
        })
    }
    function initPageList(){
        $.ajax({
            url:"/action/web_cmd.asp?act=page_list",
            type:"get",
            dataType:"json",
            success:function(data){

            }
        })
    }
});